<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>成绩等级</title>
		<script type="text/javascript">
			function grade() {
				var score = parseInt(document.myForm.txtScore.value / 10); //把输入的成绩除10取整，以判断一个分数范围
				switch (score) {
					case 10:
					case 9:
						scoreGrade = "优秀";
						break;
					case 8:
						scoreGrade = "良好";
						break;
					case 7:
						scoreGrade = "中等";
						break;		
                        case 6:
						scoreGrade = "及格";
						break;
					default:
						scoreGrade = "不及格";
						break;
				}
				alert(scoreGrade);
			}
		</script>
	</head>
	<body>
		<form name="myForm" method="get">
			<p>成绩:<input type="text" name="txtScore" /></p>
			<p><input type="button" value="确定" onclick="grade()" /> </p>
		</form>
	</body>
</html>
